<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
	</head>
	<body>
		<script>
		//循环
		//让计算机做重复的动作
		//循环+条件
		//有限和可控制的循环
		
		//while 当符合什么条件,做什么事，直到条件不符合，才结束。
			//i代表第几页
			var i = 0;
			while( i < 10 ){
				//看到第十页才停下来
				console.log(i);
				i++ ;
			}
			
			var j = 0;
		//do{}while()	
			do{
				console.log(j);
				j++ ;
			}while( j < 10 )
			
		//for 
		//0. 可以定义一个或多个的变量
		//1. 判断循环的条件是否符合
		//2. 执行{}内的代码
		//3. 执行{}内的代码后， 再执行的一句代码
		var apple = 10;
		//k代表拿到苹果的人数
		for (var k = 0; k <= apple; k++ ) {
			console.log(k);
		}
		
		
		//练习
		//1+2+3+。。。。+100
		var sum = 0;
		for (var g = 1; g <= 100; g++) {
			sum += g;
		}
		
		
		//1*2*3*4*....*100
		function n (num){
			for (var b = 1; b <= 9 ; b ++ ) {
				 num *= b;
			}
			return num;
		}
	
		
		console.log(sum);
		console.log(n(10));
		//continue
		//break;
		
		
//		双层循环
		
		
		for ( var r = 1 ; r < 10; r++ ) {
			for ( var d = 1; d <=r; d++ ) {
				document.write(r + '*'+ d + "   ");
				
			}
			document.write('<br>');
		}
		
		document.write('<br>');
		
		for ( var R = 1 ; R < 10; R++ ) {
			for ( var br = 1; br <= R; br++ ) {
					document.write('<i></i>');
				
			}
			for ( var D = 9; D >= R; D-- ) {
				document.write(R + '*'+ D + "   ");
			}
			document.write('<br>');
		}



		document.write('<br>');
		for ( var p = 1; p < 10; p++ ) {
			for ( var q = 10; q > p; q-- ) {
				document.write('<i></i>');
			}
			for( var n = 1; n <= p; n++ ) {
				document.write(n + '*'+ p + "   ");
			}
			document.write('<br>');
		}

		</script>
		<style>
			i{
				display: inline-block;
				width: 31px;
			}
		</style>
	</body>
</html>
